<template>
  <div>
    <!-- 表单弹窗   -->
    <el-dialog
      width="40%"
      :visible.sync="tableShow"
      append-to-body
    >
      <el-table :data="data"
                style="width: 100%">
        <el-table-column label="类型">
          <template slot-scope="scope">
            <el-checkbox-group v-model="checkList">
              <el-checkbox :label="item.name" v-for="item in list" :key="item"></el-checkbox>
            </el-checkbox-group>
          </template>
        </el-table-column>
        <el-table-column prop="describe" label="字段描述"/>
        <el-table-column prop="code" label="字段编码"/>
      </el-table>

      <div slot="footer" class="dialog-footer">
        <el-button size="medium" @click="handleClickDeal('cancel')"> 取 消
        </el-button>
        <el-button size="medium" type="primary" @click="handleClickDeal('submit')">
          保 存
        </el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  export default {
    name: "form-detail",
    props: {
      postDetail: {
        type: Object,
        default: {
          show: false
        }
      }
    },
    data() {
      return {
        tableShow: false,
        data: [
          {describe: '1', code: '2'}
        ],
        checkList: [],
        list: [{name: '列1', column: '1'}, {name: '列2', column: '2'}, {name: '列3', column: '3'}, {
          name: '列4',
          column: '4'
        }]
      }
    },
    methods: {
      // 点击事件处理
      handleClickDeal(type) {
        switch (type) {
          // 取消，关闭窗口
          case 'cancel':
            this.tableShow = false
            break
          // 保存
          case 'submit':
            this.tableShow = false
            break
          // 删除
          case 'delete':

            break
        }
      },
    },
    watch: {
      postDetail(value) {
        this.tableShow = value.show
      }
    }
  }
</script>

<style lang="scss" scoped>
  ::v-deep {
    .el-dialog {
      border-radius: 3px;
    }
    .el-dialog__body {
      padding: 30px;
    }

  }
</style>
